package com.codingman.springjdbcdemo1;

import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import javax.sql.DataSource;

import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.PreparedStatementCallback;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcDaoSupport;

public class EmployeeDao4 extends NamedParameterJdbcDaoSupport{
	public EmployeeDao4(DataSource dataSource) {
		super();
	    setDataSource(dataSource);
	}
	
	public void save(Employee e) {
		String query = "insert into employee values (:id,:name,:salary)";

		Map<String, Object> map = new HashMap<String, Object>();
		map.put("id", e.getId());
		map.put("name", e.getName());
		map.put("salary", e.getSalary());

		this.getNamedParameterJdbcTemplate().execute(query, map);
	}
}
